<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@page import="com.xiaoyi.sports.data.facade.dto.QuerySampleBean"%>
<%@page import="java.util.List"%>

<style>
table{border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;}
th,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
th{font-weight:bold;background:#ccc;}
input{width:600px;}
div {position: absolute; top:0px; right:0px; width:50%; height:100%; border-left-style: solid; border-left-color: #000000; overflow-y:auto;overflow-x:hidden;}
</style>

<%=new java.util.Date()%>
<table>
<tr><th>功能描述</th><th>参数</th><th>调用</th></tr>
<tr><td>直接调用</td><td><input type="text" id='param1' value="type=1&sysid='001'&busiid='b0001'&sysseq='seq0001'"/></td><td><button type="button" onclick="sampleInvoke('1')">调用</button></td></tr>
<tr><td>发Queue(direct)</td><td><input type="text" id='param2' value="type=2&sysid='001'&busiid='b0002'&sysseq='seq0002'"/></td><td><button type="button" onclick="sampleInvoke('2')">调用</button></td></tr>
<tr><td>发Queue(fanout)</td><td><input type="text" id='param3' value="type=3&sysid='001'&busiid='b0003'&sysseq='seq0003'"/></td><td><button type="button" onclick="sampleInvoke('3')">调用</button></td></tr>
<tr><td>发Queue(topic)</td><td><input type="text" id='param4' value="type=4&sysid='001'&busiid='b0004'&sysseq='seq0004'"/></td><td><button type="button" onclick="sampleInvoke('4')">调用</button></td></tr>
<tr><td>Rest Post(delete)</td><td><input type="text" id='param5' value="type=5&sysid='001'&busiid='b0005'&sysseq='seq0005'&id=?"/></td><td><button type="button" onclick="sampleInvoke('5')">调用</button></td></tr>
<tr><td>Rest Post(update)</td><td><input type="text" id='param6' value="type=6&sysid='001'&busiid='b0006'&sysseq='seq0006'&id=?"/></td><td><button type="button" onclick="sampleInvoke('6')">调用</button></td></tr>
<tr><td>Rest Post(query)</td><td><input type="text" id='param7' value="type=7&sysid='001'&busiid='b0007'&sysseq='seq0007'&id=?"/></td><td><button type="button" onclick="sampleInvoke('7')">调用</button></td></tr>
<tr><td>编程式事务(提交)</td><td><input type="text" id='param8' value="type=8&sysid='001'&busiid='b0008'&sysseq='seq0008'"/></td><td><button type="button" onclick="sampleInvoke('8')">调用</button></td></tr>
<tr><td>编程式事务(回滚)</td><td><input type="text" id='param9' value="type=9&sysid='001'&busiid='b0009'&sysseq='seq0009'"/></td><td><button type="button" onclick="sampleInvoke('9')">调用</button></td></tr>
<tr><td>dubbo call(mock)</td><td><input type="text" id='param10' value="type=10&sysid='001'&busiid='b0010'&sysseq='seq0010'"/></td><td><button type="button" onclick="sampleInvoke('10')">调用</button></td></tr>
</table>
<div id="console">

</div>
<script>
function createXMLHTTPRequest() {     
  //1.创建XMLHttpRequest对象     
  //这是XMLHttpReuquest对象无部使用中最复杂的一步     
  //需要针对IE和其他类型的浏览器建立这个对象的不同方式写不同的代码     
  var xmlHttpRequest;  
  if (window.XMLHttpRequest) {     
      //针对FireFox，Mozillar，Opera，Safari，IE7，IE8     
     xmlHttpRequest = new XMLHttpRequest();     
      //针对某些特定版本的mozillar浏览器的BUG进行修正     
       if (xmlHttpRequest.overrideMimeType) {     
           xmlHttpRequest.overrideMimeType("text/xml");     
       }     
   } else if (window.ActiveXObject) {     
       //针对IE6，IE5.5，IE5     
       //两个可以用于创建XMLHTTPRequest对象的控件名称，保存在一个js的数组中     
       //排在前面的版本较新     
       var activexName = [ "MSXML2.XMLHTTP", "Microsoft.XMLHTTP" ];     
       for ( var i = 0; i < activexName.length; i++) {     
           try {     
               //取出一个控件名进行创建，如果创建成功就终止循环     
               //如果创建失败，回抛出异常，然后可以继续循环，继续尝试创建     
              xmlHttpRequest = new ActiveXObject(activexName[i]);   
              if(xmlHttpRequest){  
                  break;  
              }  
           } catch (e) {     
           }     
       }     
   }     
   return xmlHttpRequest;  
}  
	
function get(url, callback){  
	   var req = createXMLHTTPRequest();  
	   if(req){  
	       req.open("GET", url, true);  
	       req.onreadystatechange = function(){  
	           if(req.readyState == 4){  
	               if(req.status == 200){  
	            	   callback(req.responseText);  
	               }else{  
	            	   callback("error");  
	                }  
	            }  
	        }  
	        req.send(null);  
	    }  
	}  

function post(url, params, callback){
   var req = createXMLHTTPRequest();  
   if(req){
       req.open("POST", url, true);  
       req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=gbk;"); 
       req.send(params);
       req.onreadystatechange = function(){  
           if(req.readyState == 4){  
               if(req.status == 200){  
            	   callback(req.responseText);  
                }else{  
                	callback("error");  
                }  
            }  
        }  
    }  
}  

function invokeCallback(v){
	document.getElementById("console").innerHTML = document.getElementById("console").innerHTML + v;
}

function sampleInvoke(type){
	param = document.getElementById('param' + type).value;
	post("sampleInvoke.do", param, invokeCallback);
}

var intervalId = null;
function backgroundLogsCallback(v){
	if("error" == v){
		clearInterval(intervalId);
	}
	document.getElementById("console").innerHTML = document.getElementById("console").innerHTML + v;
}

function backgroundLogs(){
	post("backgroundLogs.do", null, backgroundLogsCallback);
}

intervalId = setInterval("backgroundLogs()",2000);

</script>

